package com.xoms.admin.controller.springmvc;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.*;
import com.xoms.admin.controller.res.*;
import com.xoms.admin.controller.res.bean.*;
import com.xoms.admin.controller.springmvc.req.*;

/**
 * 商品寄存管理相关接口
 **/
@Controller
@RequestMapping(value = "/deposit", produces = "application/json")
public class SProDepositController {
	@Autowired
	com.xoms.admin.controller.ProDepositController proDepositController;

	/**
	 * 寄存-获取列表
	 **/
	@RequestMapping("/v1/getDeposits")
	@ResponseBody
	public ListResult<RProDepositBean> getDeposits(@Validated GetProDepositsParam param, BindingResult error, HttpServletRequest request, HttpServletResponse response) {
		ListResult<RProDepositBean> res = new ListResult<RProDepositBean>();
		if (error.hasErrors()) {
			res.setRescode(BaseResult.param.getCode());
			res.setMsg(error.getFieldError().getDefaultMessage());
			return res;
		}

		return proDepositController.getDeposits(param, request, response);
	}

	/**
	 * 寄存-获取详情
	 **/
	@RequestMapping("/v1/getDepositDetails")
	@ResponseBody
	public ListResult<RProDepositDetailBean> getDepositDetails(@Validated GetDepositDetailParam param, BindingResult error, HttpServletRequest request, HttpServletResponse response) {
		ListResult<RProDepositDetailBean> res = new ListResult<RProDepositDetailBean>();
		if (error.hasErrors()) {
			res.setRescode(BaseResult.param.getCode());
			res.setMsg(error.getFieldError().getDefaultMessage());
			return res;
		}

		return proDepositController.getDepositDetails(param, request, response);
	}
}
